<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="s" uri="strutsTags"%>
<%@taglib prefix="ty" uri="/wyzzTags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<head>
	<base href="<%=basePath%>">
	<title>员工社保缴费历史</title>
	<link href="<s:url value="/resource/css/style.css"/>" rel="stylesheet"
		type="text/css" />
	<script type="text/javascript" src="dwr/interface/SearchEbpAction.js"></script>
</head>
<body onload="HRMCommon.check_order();">
	<s:component template="bodyhead">
		<s:param name="pagetitle"
			value="'员工社保缴费历史('+startYear+startMonth+'-'+endYear+endMonth+')'" />
	</s:component>
	<span class="errorMessage" id="errMsg"></span>
	<s:form action="searchBeneHistory" id="searchEbpForm"
		name="searchEbpForm" namespace="/compensation" method="post">
		<s:hidden id="ebpId" name="ebpId" />
		<table width="100%" class="formtable">
			<tr>
				<td>
					<s:hidden id="id" name="detailid" />
					<s:hidden id="order" name="page.order" />
					<input type="hidden" id="operate" name="page.operate" />
					<s:hidden id="page.currentPage" name="page.currentPage" />
					<table width="100%">
						<tr>
							<s:textfield label="员工" id="empAdv" name="emp.empName" size="16"
								maxlength="64" />
							<s:select label="工作地区" id="empLocationNo"
								name="emp.empLocationNo.id" list="locationList" listKey="id"
								listValue="locationName" multiple="false" headerKey=""
								headerValue="请选择" />
							<s:select label="缴纳种类" id="beneCategory" name="beneCategory"
								list="#{'':'请选择', 0:'正常缴', 1:'补缴'}" emptyOption="false" />
							<s:select label="选择年月" id="yearMonthCate" name="yearMonthCate"
								list="#{'0':'缴费年月', '1':'所属年月'}" emptyOption="false" />
						</tr>
						<tr>
							<td align="right">
								组织单元:
							</td>
							<td>
								<s:orgselector id="orgselector1"
									name="emp.empDeptNo.departmentName"
									hiddenFieldName="emp.empDeptNo.id" isShowDisable="show" />
							</td>
							<s:select label="社保种类" id="empBenefitTypeAdv"
								name="emp.empBenefitType.id" list="ebfTypeList" listKey="id"
								listValue="benefitTypeName" multiple="false" headerKey=""
								headerValue="请选择" />
							<td align="right">
								起始年月:
							</td>
							<td>
								<s:select id="startYear" name="startYear" list="years"
									emptyOption="false" />
								<s:select id="startMonth" name="startMonth"
									list="#{'01':'01','02':'02','03':'03','04':'04','05':'05','06':'06','07':'07','08':'08','09':'09','10':'10','11':'11','12':'12'}"
									emptyOption="false" />
							</td>
							<td align="right">
								结束年月:
							</td>
							<td>
								<s:select id="endYear" name="endYear" list="years"
									emptyOption="false" />
								<s:select id="endMonth" name="endMonth"
									list="#{'01':'01','02':'02','03':'03','04':'04','05':'05','06':'06','07':'07','08':'08','09':'09','10':'10','11':'11','12':'12'}"
									emptyOption="false" />
							</td>
						</tr>
					</table>
				</td>
				<td align="center">
					<input title="[Alt+F]" accesskey="F" id="submit_button"
						class="button" type="button" onclick="submitForm();" value="查询">
					<input title="[Alt+C]" accesskey="C" class="button" type="button"
						value="重置" onClick="window.location='searchBeneHistory.action';">
				</td>
			</tr>
		</table>

		<!-- 操作 -->
		<div class="operatediv">
			<span class="operatedivleft"> <input type="hidden"
					name="searchOrExport" id="searchOrExport" /> <input type="hidden"
					name="exportType" id="exportType" /> <s:hidden id="output-ommId"
					name="outmatchModelId" /> <s:hidden id="output-ioName"
					name="outputIoName" /> <ty:auth auths="201,3 or 201,2">
					<input class="button" type="button" value="导出明细"
						onClick="exportDetail();" />
					<input class="button" type="button" value="导出汇总"
						onClick="exportSum();" />
				</ty:auth> </span>
			<span class="operatedivright">本次查询共得到<s:property
					value="page.totalRows" />条缴费历史记录</span>
		</div>

		<table id="empbenefittable" cellpadding="0" cellspacing="0"
			width="100%" border="0" class="gridtableList">
			<tr>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('emp.empDistinctNo','searchEbpForm');">员工编号</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='emp.empDistinctNo_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('emp.empName','searchEbpForm');">姓名</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='emp.empName_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpYearMonth','searchEbpForm');">缴费年月</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpYearMonth_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpBelongYearmonth','searchEbpForm');">所属年月</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpBelongYearmonth_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpStatus','searchEbpForm');">缴纳种类</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpStatus_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('beneType.benefitTypeName','searchEbpForm');">社保种类</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='beneType.benefitTypeName_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpPensionAmountb','searchEbpForm');">社保基数</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpPensionAmountb_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpHousingAmountb','searchEbpForm');">公积金基数</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpHousingAmountb_img'>
				</th>
				<th>
					<a href="#"
						onclick="HRMCommon.order_submit('ebpInsuranceAmountb','searchEbpForm');">其他基数</a>
					<img src='resource/images/arrow_.gif' width='8' height='10'
						id='ebpInsuranceAmountb_img'>
				</th>
				<th>
					个人缴社保
				</th>
				<th>
					公司缴社保
				</th>
				<th>
					备注
				</th>
				<th>
					操作
				</th>
			</tr>
			<s:if test="!ebpList.isEmpty()">
				<s:iterator value="ebpList">
					<input type="hidden"
						id="ebpBelongYearmonth<s:property value='ebpId'/>"
						name="ebpBelongYearmonth<s:property value='ebpId'/>"
						value="<s:property value='ebpBelongYearmonth' />" />
					<input type="hidden" id="ebpComments<s:property value='ebpId'/>"
						name="ebpComments<s:property value='ebpId'/>"
						value="<s:property value='ebpComments' />" />
					<tr id="<s:property value='ebpId'/>">
						<td id="ebpEmpno.empDistinctNo<s:property value='ebpId'/>"
							align="center">
							<span
								title="在职状态：<s:property value='getEmpStatusName(ebpEmpno.empStatus)'/>
所属地区：<s:property value='ebpEmpno.empLocationNo.locationName'/>
所属部门：<s:property value='ebpEmpno.empDeptNo.departmentName'/>
<s:if test="ebpEmpno.empIdentificationType==0">身份证号：<s:property value='ebpEmpno.empIdentificationNo'/></s:if>" />
								<s:property value="ebpEmpno.empDistinctNo" />
						</td>
						<td id="ebpEmpno.empName<s:property value='ebpId'/>"
							nowrap="nowrap" align="center">
							<s:property value="ebpEmpno.empName" />
						</td>
						<td id="ebpYearMonth<s:property value='ebpId'/>" nowrap="nowrap"
							align="center">
							<s:property value="ebpYearMonth" />
						</td>
						<td id="ebpBelongYearmonth<s:property value='ebpId'/>"
							nowrap="nowrap" align="center">
							<s:property value="ebpBelongYearmonth" />
						</td>
						<td id="ebpStatus<s:property value='ebpId'/>" nowrap="nowrap"
							align="center">
							<s:if test="ebpStatus==0">正常缴</s:if>
							<s:else>补缴</s:else>
						</td>
						<td id="ebpEmpno.empBenefitType<s:property value='ebpId'/>"
							nowrap="nowrap" align="center">
							<s:property value="ebpEmpno.empBenefitType.benefitTypeName" />
						</td>
						<td id="ebpPensionAmountb<s:property value='ebpId'/>"
							nowrap="nowrap" align="right">
							<s:property value="ebpPensionAmountb" />
						</td>
						<td id="ebpHousingAmountb<s:property value='ebpId'/>"
							nowrap="nowrap" align="right">
							<s:property value="ebpHousingAmountb" />
						</td>
						<td id="ebpInsuranceAmountb<s:property value='ebpId'/>"
							nowrap="nowrap" align="right">
							<s:property value="ebpInsuranceAmountb" />
						</td>
						<td id="showColumn15<s:property value='ebpId'/>" nowrap="nowrap"
							align="right">
							<s:property value="showColumn15" />
						</td>
						<td id="showColumn16<s:property value='ebpId'/>" nowrap="nowrap"
							align="right">
							<s:property value="showColumn16" />
						</td>
						<td nowrap="nowrap" align="right">
							<s:property value="ebpComments" />
						</td>
						<td align="center">
							<img
								onclick="getEbpById(this, '<s:property value="ebpId" />', '<s:property value="ebpEmpno.empName" />', '<s:property value="ebpBelongYearmonth" />');"
								alt="修改" title="修改" style="cursor: pointer;"
								src="resource/images/Search.gif"></img>
						</td>
					</tr>
				</s:iterator>
			</s:if>
			<s:else>
				<tr>
					<!-- 不存在符合条件的员工社保资料！ -->
					<td align="center" colspan="12">
						不存在符合条件的员工社保资料！
					</td>
				</tr>
			</s:else>
		</table>
		<s:pager end="page.end" pageNo="page.currentPage"
			totalRows="page.totalRows" totalPages="page.totalPages"
			formId="searchEbpForm" start="page.start" />
	</s:form>

	<!-- modify empbenefit -->
	<div id="dlgModifyEmpBenefit" style="width: 460;"
		class="prompt_div_inline">
		<div id="hiddenColumns" style="display: none"></div>
		<input type="hidden" id="ebpId_modify" name="ebpId_modify" />
		<table id="beneItems" class="prompt_div_body" width="100%">
			<tr>
				<td>
					备注:
				</td>
				<td colspan="3">
					<s:textarea id="modibeneComments" cols="36" rows="3"
						disabled="true" />
				</td>
			</tr>
			<tr>
				<td colspan="4" class="prompt_div_bottom">
					<input class="button" type="button" value="关闭"
						onclick="HRMCommon.closeDialog('dlgModifyEmpBenefit');" />
				</td>
			</tr>
		</table>
	</div>

	<script type="text/javascript">
	// 提交查询
	function submitForm() {
		var startYearMonth = document.getElementById("startYear").value + ""
				+ document.getElementById("startMonth").value;
		var endYearMonth = document.getElementById("endYear").value + ""
				+ document.getElementById("endMonth").value;
		if (startYearMonth > endYearMonth) {
			alert("查询结束年月小于起始年月！");
			return;
		}

		document.getElementById("searchOrExport").value = "";
		document.forms[0].submit();
	}

	// 导出明细；
	function exportDetail() {
		var startYearMonth = document.getElementById("startYear").value + ""
				+ document.getElementById("startMonth").value;
		var endYearMonth = document.getElementById("endYear").value + ""
				+ document.getElementById("endMonth").value;
		if (startYearMonth > endYearMonth) {
			alert("查询结束年月小于起始年月！");
			return;
		}

		document.getElementById("searchOrExport").value = "export";
		document.getElementById("exportType").value = "all";
		document.forms[0].submit();
	}

	// 导出汇总；
	function exportSum() {
		var startYearMonth = document.getElementById("startYear").value + ""
				+ document.getElementById("startMonth").value;
		var endYearMonth = document.getElementById("endYear").value + ""
				+ document.getElementById("endMonth").value;
		if (startYearMonth > endYearMonth) {
			alert("查询结束年月小于起始年月！");
			return;
		}

		document.getElementById("searchOrExport").value = "export";
		var sumType = document.getElementById("yearMonthCate").value;
		if (sumType == 0) {
			document.getElementById("exportType").value = "yearMonth";
		} else {
			document.getElementById("exportType").value = "belongYearMonth";
		}
		document.forms[0].submit();
	}

	// 显示修改页面；
	var trObj;
	var insertRowCount = 0;
	function getEbpById(obj, ebpId, empName, byearMonth) {
		trObj = obj.parentNode.parentNode;
		document.getElementById("ebpId_modify").value = ebpId;
		SearchEbpAction.getEbpItemsById(ebpId, getByIdCallback);
		function getByIdCallback(data) {
			if (data == null) {
				alert("您没有权限，也可能数据已被修改或删除，请刷新后重试！");
			}
			//在beneItems表中显示社保项目，并且全能修改；
			document.getElementById("hiddenColumns").innerHTML = ""; //清空保存隐藏域值得div；
			for ( var i = 0; i < insertRowCount; i++) {// 删除社保项目行；
				document.getElementById('beneItems' + i).parentNode
						.removeChild(document.getElementById('beneItems' + i));
			}
			var hiddenColumns = "";
			var trObj = null;
			var tdObj = null;
			insertRowCount = 0;
			var itemObj = null;
			var tdCount = 0;
			for ( var i = 0; i < data.length; i++) {
				itemObj = data[i];
				if (itemObj.esaiEsdd.esddDataType < 10
						|| itemObj.esaiEsdd.esddDataType > 16) {// 非社保项目值；
					hiddenColumns += "<input type='hidden' name='ebpColumn' id='ebpColumn"
							+ itemObj.esaiDataSeq
							+ "' value='"
							+ (itemObj.itemValue == null ? 0.00
									: itemObj.itemValue) + "'/>";
					continue;
				}

				tdCount = tdCount + 1;

				// 是社保项目值，插入一行，显示并修改；
				if (tdCount % 2 == 1) {
					trObj = document.getElementById('beneItems').insertRow(
							insertRowCount);
					trObj.id = 'beneItems' + insertRowCount;
					insertRowCount++;
				}

				// 添加一个td的显示；
				tdObj = document.createElement('td');
				tdObj.height = '27px';
				tdObj.nowrap = 'true';
				tdObj.innerHTML = itemObj.esaiEsdd.esddName + ":";
				trObj.appendChild(tdObj);
				tdObj = document.createElement('td');
				tdObj.align = 'left';
				tdObj.height = '27px';
				tdObj.innerHTML = "<input style='text-align:right;' readonly='true' class='nothinginput' type='text' name='ebpColumn' id='ebpColumn"
						+ itemObj.esaiDataSeq
						+ "' "
						+ "value='"
						+ itemObj.itemValue.toFixed(2) + "'" + " size='12'/>";
				trObj.appendChild(tdObj);
			}

			// 设置不需要修改的值；
			document.getElementById("hiddenColumns").innerHTML = hiddenColumns;
			// 显示年月，备注；
			var belongyearMonthId = "ebpBelongYearmonth" + ebpId;
			var commentsId = "ebpComments" + ebpId;
			document.getElementById("modibeneComments").value = document
					.getElementById(commentsId).value;

			$('#dlgModifyEmpBenefit').dialog(
					"option",
					"title",
					"查看" + empName + "的社保缴费(所属年月:"
							+ document.getElementById(belongyearMonthId).value
							+ ")");
			HRMCommon.openDialog("dlgModifyEmpBenefit");
		}
	}

	HRMCommon.initDialog('dlgModifyEmpBenefit');
</script>
	<jsp:include flush="true" page="../io/div_omm_select.jsp"></jsp:include>
</body>